<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <input type="button" value="更换颜色" />
    <script>
        // 1、将字符串反转
        let str = 'I Love You';
        let newStr = str.split('').reverse().join('')
        console.log(newStr);

        // 2、提取字符串参数
        let search = '?name1=value1&name2=value2';
        function getUrlParams(key, str) {
            let arr = str.slice(1, search.length).split('&')
            let obj = {}
            arr.forEach((v, index) => {
                let temp = v.split('=')
                obj[temp[0]] = temp[1]
            });
            return console.log(obj[key]);
        }
        getUrlParams('name2', search)

        // 3、点击按钮随机更换背景颜色
        document.querySelector('input').onclick = () => {
            document.body.style.backgroundColor = `rgb(${getRandow(0, 255)},${getRandow(0, 255)},${getRandow(0, 255)})`
            let temp = `rgb(${getRandow(0, 255)},${getRandow(0, 255)},${getRandow(0, 255)})`
        }
        let getRandow = (min, max) => Math.floor(Math.random() * (max - min) + min);

    </script>
</body>

</html>